{extend name="public/base" /}
{block name="head"}
	<style type="text/css">

	</style>
{/block}
{block name="body"}
<div id="fuyun-app" class="fuyun-app">
  <div class="fuyun-title">
    <h5>添加数据</h5>
    <a href="{:Url('index')}" class="layui-btn fuyun-add-btn layui-btn-small layui-btn-normal"><i class="fa fa-plus-square margin-right-5"></i>返回</a>
  </div>
  <div class="content-box">
		<form class="layui-form padding-10" method="post" action="{:Url('create')}">
			<div class="left-box">
				<div class="layui-form-item">
					<label class="layui-form-label">菜单</label>
					<div class="layui-input-block">
						<select name="menu_id">
							{volist name="menuList" id="menu"}
								<option value="{$menu.id}">{$menu.menu_name} ({$menu.url})</option>
							{/volist}
						</select>
					</div>
				</div>
				
				<div class="layui-form-item">
					<label class="layui-form-label">参数</label>
					<div class="layui-input-block">
						<input type="text" name="param" placeholder="请输入参数" class="layui-input" >
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">请求方式</label>
					<div class="layui-input-block">
						<select name="is_post">
							<option value="0">全部</option>
							<option value="1">post</option>
						</select>
					</div>
				</div>

				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="ajaxForm">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</div>
		</form>
	</div>
</div>

<script type="text/javascript">

	layui.use(['form','layer'], function(){
  	var form = layui.form();
		form.on('submit(ajaxForm)', function(data){
			var that = this;
			$(that).attr("disabled","disabled");
			$.ajax({ 
				type: "post", 
				url: data.form.action, 
				data: data.field,
				dataType: 'json', 
				success: function(result){ 
					if(result['code'] == 1){
						parent.document.location.reload();
						parent.layer.closeAll();
						parent.layer.msg(result['msg']);
					}else{
						layer.msg(result['msg']);
						$(that).removeAttr("disabled");
					}
				} 
			});
			return false;
		});
	})
</script>
{/block}



		